<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Looks up a current parameter setting of the server</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.pg-options.html">« pg_options</a></li>
      <li style="float: right;"><a href="function.pg-pconnect.html">pg_pconnect »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.pgsql.html">PostgreSQL 函数</a></li>
    <li>Looks up a current parameter setting of the server</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.pg-parameter-status" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pg_parameter_status</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pg_parameter_status</span> &mdash; <span class="dc-title">Looks up a current parameter setting of the server</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pg-parameter-status-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pg_parameter_status</strong></span>(<span class="methodparam"><span class="type"><a href="class.pgsql-connection.html" class="type PgSql\Connection">PgSql\Connection</a></span> <code class="parameter">$connection</code><span class="initializer"> = ?</span></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$param_name</code></span>): <span class="type">string</span></div>

  <p class="para rdfs-comment">
    Looks up a current parameter setting of the server.
  </p>
  <p class="para">
    Certain parameter values are reported by the server automatically at 
    connection startup or whenever their values change. <span class="function"><strong>pg_parameter_status()</strong></span> can be 
    used to interrogate these settings. It returns the current value of a 
    parameter if known, or <strong><code>false</code></strong> if the parameter is not known.
  </p>
  <p class="para">
    Parameters reported as of PostgreSQL 8.0 include <code class="literal">server_version</code>, 
    <code class="literal">server_encoding</code>, <code class="literal">client_encoding</code>, 
    <code class="literal">is_superuser</code>, <code class="literal">session_authorization</code>, 
    <code class="literal">DateStyle</code>, <code class="literal">TimeZone</code>, and <code class="literal">integer_datetimes</code>.
    (<code class="literal">server_encoding</code>, <code class="literal">TimeZone</code>, and 
    <code class="literal">integer_datetimes</code> were not reported by releases before 8.0.) Note that 
    <code class="literal">server_version</code>, <code class="literal">server_encoding</code> and <code class="literal">integer_datetimes</code> 
    cannot change after PostgreSQL startup.
  </p>
  <p class="para">
    PostgreSQL 7.3 or lower servers do not report parameter settings,
    <span class="function"><strong>pg_parameter_status()</strong></span>
    includes logic to obtain values for <code class="literal">server_version</code> and 
    <code class="literal">client_encoding</code>
    anyway. Applications are encouraged to use <span class="function"><strong>pg_parameter_status()</strong></span> rather than ad 
    hoc code to determine these values.
  </p>
  <div class="caution"><strong class="caution">警告</strong>
    <p class="para">
      On a pre-7.4
      PostgreSQL server, changing <code class="literal">client_encoding</code> via <code class="literal">SET</code> after connection startup will 
      not be reflected by <span class="function"><strong>pg_parameter_status()</strong></span>.
     </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pg-parameter-status-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">connection</code></dt>

     <dd>

      <p class="para">An <span class="classname"><a href="class.pgsql-connection.html" class="classname">PgSql\Connection</a></span> instance.
When <code class="parameter">connection</code> is unspecified, the default connection is used.
The default connection is the last connection made by <span class="function"><a href="function.pg-connect.html" class="function">pg_connect()</a></span>
or <span class="function"><a href="function.pg-pconnect.html" class="function">pg_pconnect()</a></span>.
<div class="warning"><strong class="warning">警告</strong><p class="simpara">As of PHP 8.1.0, using the default connection is deprecated.</p></div></p>
     </dd>

    
    
     <dt>
<code class="parameter">param_name</code></dt>

     <dd>

        <p class="para">
         Possible <code class="parameter">param_name</code> values include <code class="literal">server_version</code>, 
        <code class="literal">server_encoding</code>, <code class="literal">client_encoding</code>, 
        <code class="literal">is_superuser</code>, <code class="literal">session_authorization</code>, 
        <code class="literal">DateStyle</code>, <code class="literal">TimeZone</code>, and 
        <code class="literal">integer_datetimes</code>.  Note that this value is case-sensitive.
        </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pg-parameter-status-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">A <span class="type">string</span> containing the value of the parameter, <strong><code>false</code></strong> on failure or invalid
  <code class="parameter">param_name</code>.</p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.pg-parameter-status-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
 <td>8.1.0</td>
 <td>
  现在 <code class="parameter">connection</code> 参数接受 <span class="classname"><a href="class.pgsql-connection.html" class="classname">PgSql\Connection</a></span>
  实例，之前接受 <a href="language.types.resource.html" class="link">资源(resource)</a>。
 </td>
</tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.pg-parameter-status-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1922">
    <p><strong>示例 #1 <span class="function"><strong>pg_parameter_status()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />&nbsp;&nbsp;$dbconn&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">pg_connect</span><span style="color: #007700">(</span><span style="color: #DD0000">"dbname=publisher"</span><span style="color: #007700">)&nbsp;or&nbsp;die(</span><span style="color: #DD0000">"Could&nbsp;not&nbsp;connect"</span><span style="color: #007700">);<br /><br />&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"Server&nbsp;encoding:&nbsp;"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">pg_parameter_status</span><span style="color: #007700">(</span><span style="color: #0000BB">$dbconn</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"server_encoding"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Server encoding: SQL_ASCII
</pre></div>
    </div>
   </div>
  </p>
 </div>

</div></div></div></body></html>